/*
 * @(#)AttributeInfo.java $version 2010. 8. 11
 *
 * Copyright 2007-2010 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nhncorp.usf.core.config;

import java.util.HashMap;
import java.util.Map;

/**
 * 환경 파일로부터의 OperationAttribute 정보를 넣을 모델.
 *
 * @author Web Platform Development Team
 */
public class AttributeInfo {
    /**
     * 기본 제공되는 attribute 명
     */
    public enum ATTRIBUTE_NAME {
        runtimeConfigBuilder, exceptionHandler, schemaVersion, pageBufferSize, devMode, templateUpdateDelay,
        actionParameter, checkDataModel, serviceExecutor, parameterUri, resultGenerator, ignoreException,
        freemarkerLogger, freemarkerExceptionHandler, freemarkerOutputEncoding, freemarkerURLEscapingCharset
    }

    /**
     * OperationAttributes 객체 참조자.
     */
    private static AttributeInfo attributeInfo;

    /**
     * {@link Map} to manage Operation Attirbutes.
     */
    private Map<String, String> attributes = new HashMap<String, String>();

    /**
     * operationAttributeInfo 객체 반환.
     *
     * @return attributeInfo the AttributeInfo
     */
    public static AttributeInfo getInstance() {
        if (attributeInfo == null) {
            attributeInfo = new AttributeInfo();
        }

        return attributeInfo;
    }

    /**
     * put Attribute to {@link Map}.
     *
     * @param name  the attribute name
     * @param value the attribute value
     */
    public void addAttribute(String name, String value) {
        attributes.put(name, value);
    }

    /**
     * get Attribute from {@link Map}.
     *
     * @param name the attribute name
     * @return get Attribute for name
     */
    public String getAttribute(String name) {
        return attributes.get(name);
    }

    /**
     * Gets the attribute.
     *
     * @param attributeName the attribute name
     * @return the attribute
     */
    public String getAttribute(ATTRIBUTE_NAME attributeName) {
        return attributes.get(attributeName.name());
    }

    /**
     * Returns <tt>true</tt> if this map contains a mapping for the specified
     * attribute of name.
     *
     * @param name the attribute name
     * @return the attirbute exist for name
     */
    public boolean containsKey(String name) {
        return attributes.containsKey(name);
    }

    /**
     * clean all object
     */
    public void clear() {
        attributes.clear();
    }

}
